<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<title>修改角色</title>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<!--导入核心文件-->
		<script src="../../bootstrap3/js/holder.js" type=""></script>
		<link href="../../bootstrap3/css/bootstrap.css" rel="stylesheet" type="text/css">
		<script src="../../bootstrap3/jquery-1.9.1.min.js" type=""></script>
		<script src="../../bootstrap3/js/bootstrap.js" type=""></script>
		<!-- 字体图标 -->
		<link rel="stylesheet" href="../../bootstrap3/font-awesome-4.7.0/css/font-awesome.css"/>
		<link rel="stylesheet" type="text/css" href="../../css/style.css"/>
	</head>

	<body>
		<div id="wrap">
			<div id="top_content">
					<div id="header">
						<div id="rightheader">
							<p>2009/11/20<br /></p>
						</div>
						<div id="topheader">
							<h1 id="title"><a href="#">修改角色信息</a></h1>
						</div>
						<div id="navigation"></div>
					</div>
				<div id="content">
					<p id="whereami"></p>
					<!--<h1>add Role info:</h1>-->
					<form id="form-change-info">
						<table cellpadding="0" cellspacing="0" border="0" class="form_table">
							<tr>
								<td valign="middle" align="right">角色ID:</td>
								<td valign="middle" align="left">
									<input type="text" class="inputgri" name="roleId" id="inp-roleId" readonly="readonly"/>
								</td>
							</tr>
							<tr>
								<td valign="middle" align="right">角色名称:</td>
								<td valign="middle" align="left">
									<input type="text" class="inputgri" name="roleName" id="inp-roleName" />
								</td>
							</tr>
							<tr>
								<td valign="middle" align="right">角色编号：</td>
								<td valign="middle" align="left">
									<input type="text" class="inputgri" name="adminGrade"  id="inp-adminGrade"/>
								</td>
							</tr>
							<tr>
								<td valign="middle" align="right">备注：</td>
								<td valign="middle" align="left">
									<textarea placeholder="请输入内容"  name="remarks" id="tex-remarks"></textarea>
								</td>
							</tr>
						</table>
						<p>
							<input type="button" class="cart-del-sel btn btn-default btn-xs" id="btn-chenge-info" onclick="changeInfo()" value="修改"/>
							<input type="reset" class="cart-del-sel btn btn-default btn-xs" value="重置"/>
							<input type="button" class="cart-del-sel btn btn-default btn-xs" value="返回" onclick="location='roleList.html'"/>
						</p>
					</form>
				</div>
			</div>
			<div id="footer">
				<div id="footer_bg">ABC@126.com</div>
			</div>
		</div>
		<script type="text/javascript" src="../../js/jquery-getUrlParam.js"></script>
		<script type="text/javascript">
			$(document).ready(function() {
				showRoleInfo();

				/*$("#btn-change-info").click(function () {
                    changeInfo();
                })*/
			});
			let roleId = $.getUrlParam("roleId");

			function changeInfo(){
					$.ajax({
						"url":"/role/change_info",
						"data":$("#form-change-info").serialize(),
						"type":"post",
						"dataType":"json",
						"success":function (json) {
							if(json.state===2000){
								alert("修改角色成功！");
							}else{
								alert("修改角色失败！"+json.message);
							}
						},
						"error":function () {
							alert("您的登录信息已过期！请重新登录");
							//location.href="login.html";
						}
					});
			}

            function showRoleInfo() {
                $.ajax({
                    "url":"/role/get_role_by/"+roleId,
                    "type":"get",
                    "dataType":"json",
                    "success":function(json) {
                        if (json.state === 2000) {
                            $("#inp-roleId").val(json.data.roleId);
                            $("#inp-roleName").val(json.data.roleName);
                            $("#inp-adminGrade").val(json.data.adminGrade);
                            $("#tex-remarks").val(json.data.remarks);
                        } else {
                            alert("读取失败！" + json.message);
                        }
                    }
                });
            }

		</script>
	</body>
</html>
